#delimit;

set more off;

capture log close;

local t2="specify here the folder path where the data are stored";
local t1="specify here the folder path where you want the output data to be stored";

**This do-file allows you to sort files for each module for Wave 2 data;

log using `t1'sort_merge_w2rel231, replace;

drop _all;

set mem 400m;

use `t2'sharew2_rel2-3-1_cv_r;
compress;
sort hhid2 cvid;
save `t1'sharew2_rel2-3-1_cv_r1, replace;
clear;

use `t2'sharew2_rel2-3-1_cv_h;
compress;
sort hhid2;
keep cv178_ hhid2;
save `t1'sharew2_rel2-3-1_cv_h1, replace;
clear;

use `t2'sharew2_rel2-3-1_ch;
compress;
sort mergeid;
save `t1'sharew2_rel2-3-1_ch1, replace;

clear;
use `t2'sharew2_rel2-3-1_dn;
compress;
sort  mergeid;

save `t1'sharew2_rel2-3-1_dn1, replace;

clear;

use `t2'sharew2_rel2-3-1_ep;
compress;
sort  mergeid;
save `t1'sharew2_rel2-3-1_ep1, replace;
clear;


use `t2'sharew2_rel2-3-1_ft;
compress;
sort  mergeid;
save `t1'sharew2_rel2-3-1_ft1, replace;
clear;


use `t2'sharew2_rel2-3-1_hc;
compress;
sort  mergeid;
save `t1'sharew2_rel2-3-1_hc1, replace;
clear;

use `t2'sharew2_rel2-3-1_hh;
compress;
sort  mergeid;
save `t1'sharew2_rel2-3-1_hh1, replace;
clear;

use `t2'sharew2_rel2-3-1_ho;
compress;
sort  mergeid;
save `t1'sharew2_rel2-3-1_ho1, replace;
clear;

use `t2'sharew2_rel2-3-1_mh;
compress;
sort  mergeid;
save `t1'sharew2_rel2-3-1_mh1, replace;
clear;


use `t2'sharew2_rel2-3-1_ph;
compress;
sort  mergeid;
save `t1'sharew2_rel2-3-1_ph1, replace;

clear;

use `t2'sharew2_rel2-3-1_sp;
compress;
sort  mergeid;
save `t1'sharew2_rel2-3-1_sp1, replace;
clear;

use `t2'sharew2_rel2-3-1_gv_weights;
compress;
sort  mergeid;
save `t1'sharew2_rel2-3-1_gv_weights1, replace;

use `t2'sharew2_rel2-3-1_gv_isced;
compress;
sort  mergeid;
save `t1'sharew2_rel2-3-1_gv_isced1, replace;

use `t2'sharew2_rel2-3-1_imputations;
compress;
sort mergeid;
save `t1'sharew2_rel2-3-1_imputations1, replace;
clear;


log close;
